<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" href="/css/common_lib/sencha-touch.css" />
<link rel="stylesheet" href="/css/common_lib/sencha_icons.css" />
<style>
	.ntext {
		font-size : 12px;
		color : #555555;
	}
</style>
<script src="/js/common_lib/jquery-1.7.min.js"> </script>
<script src="/js/common_lib/json2.js"> </script>
<script src="/js/common_lib/sencha-touch-debug-w-comments.js"> </script>
<script type="text/javascript" src="/js/common_lib/gear5-0.3.js"> </script>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"> </script>
<script src="/js/my_lib/Class.js"> </script>
<script src="/js/my_lib/Util.js"> </script>
<script src="/js/my_lib/DataStructure2.js"> </script>
<script src="/js/carcenter2/getData.js"> </script>
<script src="/js/carcenter2/extModels.jsp"> </script>
<script src="/js/carcenter2/extStores.js"> </script>
<script src="/js/carcenter2/panel/index.js"> </script>
<script src="/js/carcenter2/panel/googlemap.js"> </script>
<script src="/js/carcenter2/panel/regPanel.js"> </script>
<script src="/js/carcenter2/panel/mapPanel.js"> </script>
<script src="/js/carcenter2/panel/favPanel.js"> </script>
</head>
<body>
</body>
<script>
	onHashFunc = function(e){};
	
	onHashFuncReal = function(e) {
		var thisUrl = e.newURL;
		var idx = thisUrl.lastIndexOf("#");
		var pageId = "";
		if(idx != -1) {
			pageId = thisUrl.substr( idx+1 );
		}
		// hashchange 즉 뒤로가기등을 사용하여 이동할때는 리로드 하지 않는다.
		main.reload = false;
		
		main.goPage(pageId);
	};
	onPageShow = function(e) {};
	
	onPageShowReal = function(e) {
		// e.srcElement 파이어폭스에서 안됨.
		// e.target 크롬 , 파이어폭스 지원.
		var thisUrl = e.target.URL;
		var idx = thisUrl.lastIndexOf("#");
		var pageId = "";
		if(idx != -1) {
			pageId = thisUrl.substr( idx+1 );
		}
		if(main.panel) main.goPage(pageId);
	}
	
	$(document).ready(function(){
		main.reload = true;
		
		main.login = {
			login_email : '',
			mem_name : '',
			mem_nickname : '',
			toString : function() {
				return 	"{login_email : '"+ this.login_email +"' , "
				      + "mem_name : '"+ this.mem_name +"' , "
				      + "mem_nickname : '"+ this.mem_nickname +"'}";
			},
			getLogin_info : function() {
				var login_info = localStorage.getItem('zpyr.carcenter_app.login_info');
				if(!login_info) login_info = this.toString();
				login_info = eval('('+    login_info     +')');
			
				this.login_email 	= login_info.login_email;
				this.mem_name 	= login_info.mem_name;
				this.mem_nickname = login_info.mem_nickname;
			}
		};
		// 로그인 정보를 가져온다.
		main.login.getLogin_info();
		
		window.onhashchange = onHashFunc;
		
		window.onpageshow = onPageShow;
		
		main.winWidth = $('body').width()-20;
		main.winHeight = $('body').height()-110;
		
		main.goPage = function(pageId , animation) {
			var panel;
			var panelList = [ map.panel.search , map.panel.carcenter , map.panel.namesearch , map.panel.list , map.panel.main ];
			
			var needLogin = [ 'paddCarc' ];
			needLogin = new Array();
			needLogin.push('paddCarc');
			for(i in needLogin) {
				if(pageId == needLogin[i] )  // 로그인이 필요한 페이지라면, 
					if(!main.login.login_email) return; // 로그인이 안되어있으면 스탑.
			}
			
			if(!animation) animation = 'slide';
				console.log(pageId);
				switch(pageId) {
				case 'psearch' :
					panel = map.panel.search;
					break;
				case 'pcarcenter' :
					panel = map.panel.carcenter;
					break;
				case 'pnamesearch' :
					panel = map.panel.namesearch;
					break;
				case 'plist' :
					panel = map.panel.list;
					break;
				case 'paddCarc' :
					panel = reg.panel.addCarc;
					break;
				case 'plogin' :
					panel = reg.panel.login;
					if(main.login.login_email) panel = reg.panel.logindone;
					break;
				case 'pjoin' :
					panel = reg.panel.join;
					break;
				case 'plogindone' :
					panel = reg.panel.logindone;
					if(!main.login.login_email) panel = reg.panel.login;
					break;
				case 'pfavlist' :
					panel = fav.panel.list;
					break;
				case '' :
					panel = map.panel.main;
					break;
			};
			main.panel.cardSwitchAnimation = animation;
			main.panel.layout.setActiveItem( panel );
			main.panel.doLayout();
		//	history.pushState(pageId , 'title_'+pageId , '#'+pageId);
		};
		
	});
</script>
</html>